﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Configuration;

namespace DBLayer
{
    class DBConnection
    {
        private SqlConnection con;
        private static DBConnection instance = null;

        private DBConnection()
        {

            //Ignore for now please.

            //Console.WriteLine("connect found");
            //con = new SqlConnection();
            //con.ConnectionString = ConfigurationManager.ConnectionStrings["connect"].ConnectionString;


            //Connnection information for Balder
            con = new SqlConnection("User id=dmaa0212a_6;" +
                                           "Password=MaaGodt;" +
                                           "Server=balder.ucn.dk;" +
                                           "Trusted_Connection=no;" +
                                           "Database=dmaa0212a_6;" +
                                           "Connection Timeout=10");

            try
            {
                //Open DB connection
                con.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine("Fail her: " + e.ToString());     //fail msg
            }


            //Console.WriteLine("succes?");

        }


        /**
         * Get instance of ConnectionDB - Ensures Singleton
         * 
         * @return ConnectionDB instance
         **/
        public static DBConnection getInstance()
        {
            if (instance == null)
            {
                instance = new DBConnection();
            }
            return instance;
        }


        /**
         * returns the con. See the DBCity constructor for usage.
         * */
        public SqlConnection getDBCon()
        {
            return con;
        }





    }
}
